package myky.com.doctorapp.presenter;

import io.reactivex.disposables.Disposable;
import myky.com.doctorapp.base.BasePresenterIm;
import myky.com.doctorapp.base.RxPageSubscribe;
import myky.com.doctorapp.contract.MyConsultContract;
import myky.com.doctorapp.entity.MyConsultEntity;
import myky.com.doctorapp.entity.PageEntity;
import myky.com.doctorapp.model.MyConsultModel;

public class MyConsultPresenter extends BasePresenterIm<MyConsultContract.View> implements MyConsultContract.Presenter {

    MyConsultModel myConsultModel;

    public MyConsultPresenter() {

        myConsultModel=new MyConsultModel();
    }

    @Override
    public void findMyConsult(int startPage, int endPage) {

        myConsultModel.findMyConsult(startPage, endPage).subscribe(new RxPageSubscribe<MyConsultEntity>() {
            @Override

            protected void onSuccess(MyConsultEntity myConsultEntity, PageEntity pageEntity) {


                if(myConsultEntity.getSpecialistConsults()!=null){


                mView.showPageEntity(pageEntity);

                mView.showDataSuccess(myConsultEntity.getSpecialistConsults());

                }




            }

            @Override
            protected void onFailed(int code, String msg) {


                mView.logCat(msg);

            }

            @Override
            public void onSubscribe(Disposable d) {

                addSubscription(d);

            }
        });


    }
}
